<!-- The ref attr used to find the swiper instance -->
<template>
  <div class="sw-wrapper">
    <swiper :options="swiperOption" v-if="isSwiperShow">
      <!-- slides -->
      <swiper-slide v-for="item in swiperList" :key="item.id">
        <img class="swiper-img" :src="item.imgUrl" />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
  export default {
    name: 'HomeSwiper',
    props: {
      swiperList: Array
    },
    data: function() {
      return {
        swiperOption: {
          pagination: '.swiper-pagination',
          pagenationType: 'progress',
          loop: true,
          effect: 'coverflow',
          type: 'progressbar',
          autoplay: 2000,
        }
      }
    },
    computed: {
      isSwiperShow: function() {
        return this.swiperList.length;
      }
    }
  }
</script>

<style lang="stylus" scoped>
  .sw-wrapper>>>.swiper-pagination-bullet-active {
    background-color: #fff;
  }

  .sw-wrapper {
    overflow: hidden;
    width: 100%;
    background-color: #eee;
  }

  .sw-wrapper .swiper-img {
    width: 100%;
    height: 100%;
  }
</style>
